package com.example.houduan.Service.Impl;

import com.example.houduan.Mapper.DrugCompanyMapper;
import com.example.houduan.Pojo.DrugCompany;
import com.example.houduan.Service.DrugCompanyService;
import com.example.houduan.Utils.PageModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DrugCompanyServiceImpl implements DrugCompanyService {

    @Autowired
    DrugCompanyMapper drugCompanyMapper;

    @Override
    public List<DrugCompany> getAllDrugCompany() {
        return drugCompanyMapper.selectAllDrugCompany();
    }

    @Override
    public PageModel getDrugCompanyPage(int num, int size) {
        int count = drugCompanyMapper.selectDrugCompanyCount();
        PageModel pm=new PageModel(num,count,size);
        pm.setList(drugCompanyMapper.selectDrugCompanyLimit((num-1)*size,size));
        return pm;
    }

    @Override
    public int deleteDrugCompany(Integer company_id) {
        return drugCompanyMapper.deleteDrugCompany(company_id);
    }

    @Override
    public int updateDrugCompany(DrugCompany drugCompany) {
        return drugCompanyMapper.updateDrugCompany(drugCompany);
    }

    @Override
    public int addDrugCompany(DrugCompany drugCompany) {
        return drugCompanyMapper.insertDrugCompany(drugCompany);
    }

    @Override
    public List<DrugCompany> getDrugCompanyByConditions(Integer company_id, String company_name, String city_name) {
        return drugCompanyMapper.selectDrugCompanyByConditions(company_id,company_name,city_name);
    }
}
